using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PietschSoft.VE;

namespace SecurityLinkUp
{
    public partial class ChapterSummaryCtrl : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void LoadInfo(Guid ChapterID)
        {    
            // clear the map
            Map.Pushpins.Clear();

            // get the community
            Chapter c = ChapterData.GetChapter(ChapterID);

            // update the community info
            ChapterTitle.Text = c.name;
            ChapterDescription.Text = c.description;
            ChapterLink.NavigateUrl = "/ViewChapter.aspx?ChapterID=" + ChapterID;

            // If there is a location for this chapter, display it on the map
            if (c.HasPosition)
            {
                LatLong Position = new LatLong(c.geolat, c.geolong);
                Pushpin p = new PietschSoft.VE.Pushpin(c.uid.ToString(), Position, null, c.name, "<a href=/ViewChapter.aspx?ChapterID=" + c.uid.ToString() + ">Go to this chapter</a>");
                Map.Pushpins.Add(p);
                Map.Latitude = c.geolat;
                Map.Longitude = c.geolong;
                Map.Zoom = 10;
            }

            Meeting m = MeetingData.GetNextMeeting(new Guid(ChapterID.ToString()));
            if (m != null)
            {
                MeetingLink.Text = m.Start.ToShortDateString() + " - " + m.Title;
                MeetingLink.NavigateUrl = "/ViewMeeting?MeetingID=" + m.uid;
            }
            else
            {
                MeetingLink.Text = "No future meetings";
                MeetingLink.NavigateUrl = "";
            }
            
        }



            
    }
}